import time

from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from 测试.common.Utils import Driver
import argparse



class Update:
     url = ""
     driver = ""

     def __init__(self):
         self.driver = Driver.driver
         self.url = "http://127.0.0.1:9580/sign-in.html"
     def test(self):
         self.driver.implicitly_wait(4)
         self.driver.find_element(By.CSS_SELECTOR, "#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post").click()
         #选模块C++
         self.driver.find_element(By.CSS_SELECTOR, "#article_post_borad").click()
         self.driver.find_element(By.CSS_SELECTOR, "#article_post_borad > option:nth-child(2)").click()
         # 标题
         self.driver.find_element(By.CSS_SELECTOR, "#article_post_title").click()

         ele = self.driver.find_element(By.CSS_SELECTOR, "#article_post_title")
         ele.send_keys("测试")
         # 内容
         ele.send_keys(Keys.TAB)
         ele2 = self.driver.switch_to.active_element
         ele2.send_keys("你好")
         # 提交
         time.sleep(2)
         self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
         self.driver.find_element(By.CSS_SELECTOR, "#article_post_submit").click()
         time.sleep(1)
         #没标题
         self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post").click()
         text=self.driver.find_element(By.CSS_SELECTOR, "#bit-forum-content > div.page-body > div > div > div.card-body > div:nth-child(2) > label > strong").text
         assert text=="标题"
         # self.driver.find_element(By.CSS_SELECTOR, " #setting_submit_nickname").click()
         # self.driver.find_element(By.CSS_SELECTOR, " #setting_submit_nickname").click()
         # self.driver.find_element(By.CSS_SELECTOR, " #setting_submit_nickname").click()